/*
 *   Author:
 *   vyouzhi <vyouzhi@163.com>
 *   http://www.xda.cn
 *
 *   File:                    MEM_LIB
 *   Create Date:      2011-07-17 00:31:32
 */

#ifndef MEM_LIB_H_     
#define MEM_LIB_H_

#define SQL_DBG_MEM 1

#if !defined( SQLPROXY_DBG_MEM )

	#include <stdlib.h>
 
	#define SQLMalloc(size) malloc(size)
	#define SQLCalloc(nItem, itemSize) calloc(nItem, itemSize)
	#define SQLRealloc(ptr, size) realloc(ptr, size)
	#define SQLFree(ptr) free(ptr)

#else
	#include <sys/types.h>
	#define SQLMalloc(size)	SQLMallocEx((size), __FUNCTION__, __FILE__, __LINE__)
	#define SQLCalloc(nmemb, size)	SQLCallocEx((nmemb), (size), __FUNCTION__, __FILE__, __LINE__)
	#define SQLRealloc(ptr, size)	SQLReallocEx((ptr), (size), __FUNCTION__, __FILE__, __LINE__)
	#define SQLFree(ptr)	SQLFreeEx((ptr), __FUNCTION__, __FILE__, __LINE__)

	void *SQLMallocEx(size_t size, const char *caller, const char *fileName, int lineNo);
	void *SQLCallocEx(size_t nmemb, size_t size, const char *caller, const char *fileName, int lineNo);
	void *SQLReallocEx(void *ptr, size_t size, const char *caller, const char *fileName, int lineNo);
	void SQLFreeEx(void *ptr, const char *caller, const char *fileName, int lineNo);

#endif
#endif /* MEM_LIB_H */
/* vim: set ts=4 sw=4: */

